# 导入pandas
import pandas as pd
import pymysql


# 准备数据库
cn = pymysql.connect(
    host='localhost',
    user='root',
    password='kaikai',
    database='news',
    port=3306,
    charset='utf8'
)

# 读取数据 pd.read_sql(sql语句, con=数据库连接对象)
data = pd.read_sql('select * from company_news', cn)
print(data)

# 关闭数据库连接对象
cn.close()
